package com.banksoft.cps.controller.admin;

import com.banksoft.cps.bean.Company;
import com.banksoft.cps.bean.Device;
import com.banksoft.cps.bean.MonitorVideo;
import com.banksoft.cps.bean.query.DeviceQuery;
import com.banksoft.cps.bean.query.MonitorVideoQuery;
import com.banksoft.cps.bean.warpper.DeviceWarpper;
import com.banksoft.cps.controller.ControllerConstants;
import com.banksoft.cps.service.CompanyService;
import com.banksoft.cps.service.DeviceService;
import com.banksoft.cps.service.MonitorVideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by rongzhao.zhu on 2018/11/7.
 */
@Controller
@RequestMapping("/admin/map/")
public class AdminMapController extends ControllerConstants {
    @Autowired
    MonitorVideoService monitorVideoService;
    @Autowired
    CompanyService companyService;
    @Autowired
    DeviceService deviceService;
    @RequestMapping(value = "listForMapByCompanyId",produces = "application/json;charset=utf-8")
    @ResponseBody
    public String listForMapByCompanyId(String companyId){
        MonitorVideoQuery query = new MonitorVideoQuery();
        DeviceQuery deviceQuery = new DeviceQuery();
        query.setCompanyId(companyId);
        deviceQuery.setCompanyId(companyId);
        List<MonitorVideo> list =  monitorVideoService.list(query);
        Company company = companyService.findById(companyId);
        List<DeviceWarpper> deviceList = deviceService.listWarpper(deviceQuery);
        Map<String,Object> map = new HashMap<>();
        map.put("videoList",list);
        map.put("jlbList",deviceList);
        map.put("company",company);

        return toJSONString(createDataTip(map));
    }
}
